﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucProductOrigin : System.Web.UI.UserControl
    {
        cmsXuatXuDO objXuatXu = new cmsXuatXuDO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["OID"] != null)
            {
                objXuatXu.XuatXuID = int.Parse(Request.QueryString["OID"].ToString());
                InitForm();
            }
        }

        protected void InitForm()
        {
            objXuatXu = new cmsXuatXuBL().Select(objXuatXu);
            txtXuatXu.Text = objXuatXu.XuatXu.ToString();
            if (!string.IsNullOrEmpty(Convert.ToString(objXuatXu.MoTa)))
            {
                txtMoTa.Text = objXuatXu.MoTa.ToString();
            }
            try
            {
                //   drpParentID.SelectedValue = objLSanPham.ParentID.ToString();
            }
            catch
            {
            }
        }

        protected void SetObject()
        {
            objXuatXu.XuatXu = txtXuatXu.Text;
            objXuatXu.MoTa = txtMoTa.Text;
        }

        protected void btnHuy_Click(object sender, EventArgs e)
        {

        }
        long i;
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            SetObject();
            if (objXuatXu.XuatXuID <= 0)
            {
                i = new cmsXuatXuBL().Insert(objXuatXu);
                Functions.Alert("Thêm mới thành công", "Default.aspx?Page=ListProductOrigin");
            }
            else
            {
                i = new cmsXuatXuBL().Update(objXuatXu);
                //    i = objXuatXu.NhanHieuID;
                Functions.Alert("Cập nhật thành công", "Default.aspx?Page=ListProductOrigin");
            }
        }
 
    }
}